println "Test"


fileCopy = {
	println "Test"
    ext = ".template"
    f = it.getCanonicalPath()
    if (it.isDirectory() ) {
        if (it.getName().startsWith(".")) {
            return
        }
        else if (it.getName().equals("target")) {
            return
        }
    }
    it.eachDir(fileCopy)


    it.eachFile {
        if ( it.isFile()  && it.getName().endsWith(ext)) {
            df = new File(it.getAbsolutePath().substring(0,it.getAbsolutePath().length()-ext.length()))
            if (!df.exists()) {
		log.info ("Copying template "+it.getAbsolutePath()+" to "+df.getName())
               ant.copy(file: it, tofile: df)
            }
	    else {
		log.info(df.getName()+" already exists")
	    }
        }
    }
}

fileCopy(project.basedir)

